package easy;

import java.util.ArrayList;
import java.util.List;

public class Solution_830 {

    public List<List<Integer>> largeGroupPositions(String s) {
        s += ' ';
        List<List<Integer>> list = new ArrayList<>();
        char[] chars = s.toCharArray();
        for (int i = 1, preIndex = 0; i < chars.length; i++) {
            if (chars[i] != chars[preIndex]) {
                if (i - preIndex >= 3) {
                    List<Integer> temp = new ArrayList<>();
                    temp.add(preIndex);
                    temp.add(i - 1);
                    list.add(temp);
                }
                preIndex = i;
            }
        }
        return list;
    }

    public static void main(String[] args) {
        Solution_830 model = new Solution_830();
        System.out.println(model.largeGroupPositions("abcdddeeeeaabbbcd"));
        System.out.println(model.largeGroupPositions("abbxxxxzzy"));
        System.out.println(model.largeGroupPositions("aba"));
    }
}
